package com.shakev.coupon.web.controller;

import com.shakev.coupon.es.model.Goods;
import com.shakev.coupon.es.service.EGoodsDetailService;
import com.shakev.coupon.taobao.model.GoodsDetail;
import com.shakev.coupon.web.model.GoodsDetailVo;
import com.shakev.coupon.web.model.base.RestResponse;
import com.shakev.coupon.web.model.vo.home.HomeVo;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName HomeController
 * @Description TODO
 * @Author 李伟松
 * @CreateDate 2019-05-08 下午 9:59
 * @UpdateDate 2019-05-08 下午 9:59
 * @Version 1.0
 */
@RestController
public class HomeController {


    @Resource
    EGoodsDetailService goodsDetailService;

    //首页加载的内容
    @RequestMapping("/index")
    public RestResponse index() {
        HomeVo home = new HomeVo();
//        categorySevice.listHomeCategoryList();
        List<GoodsDetail> hotCouponList = goodsDetailService.pageQuery(3,3,null).getContent();
        home.setHotCoupons(hotCouponList);
        List<GoodsDetail> cheaps = goodsDetailService.pageQuery(2,10,null).getContent();
        home.setCheaps(cheaps);
        return RestResponse.success(home);
    }

    //首页分类（首次进入软件时请求）
    @RequestMapping("/index/category/list")
    public RestResponse categoryList(String id) {
//        categorySevice.listHomeCategoryList();
        return null;
    }


    //为你推荐

    /**
     * 有 userId 获取最近5条商品二级分类以下相似商品列表 如果没有记录 按未登录用户推商品
     *
     * @param pageNo
     * @return
     */
    @RequestMapping("/index/recommends/list")
    public RestResponse recommends(Integer pageNo,Integer pageSize) {
        Page<GoodsDetail> goodsList = goodsDetailService.pageQuery(pageNo, pageSize, null);
        return RestResponse.success(goodsList.getContent());
    }

    //传 1级分类id
    @RequestMapping("/index/category")
    public RestResponse category(String id) {
//        categorySevice.listHomeCategoryList();
        return null;
    }

    //传 广告id
    @RequestMapping("/index/advert")
    public RestResponse advert(String aId) {
        return null;
    }

    /**
     * 限时抢券
     */
    @RequestMapping("/index/limitTime/list")
    public RestResponse limitTime(Integer pageNo,Integer pageSize) {
        Page<GoodsDetail> goodsList = goodsDetailService.pageQuery(pageNo, pageSize, null);
        return RestResponse.success(goodsList.getContent());
    }

    /**
     * 热销榜
     */
    @RequestMapping("/index/sale/list")
    public RestResponse sale(Integer pageNo,Integer pageSize) {
        Page<GoodsDetail> goodsList = goodsDetailService.pageQuery(pageNo, pageSize, null);
        return RestResponse.success(goodsList.getContent());
    }

    //火爆优惠券
    @RequestMapping("/index/hot/list")
    public RestResponse hot(Integer pageNo,Integer pageSize) {
        Page<GoodsDetail> goodsList = goodsDetailService.pageQuery(pageNo, pageSize, null);
        return RestResponse.success(goodsList.getContent());
    }

    //火爆优惠券、实惠好货、为你推荐 、 生活馆-今日必买
    @RequestMapping("/detail")
    public RestResponse detail(String iid) {
        GoodsDetailVo vo;
        return RestResponse.success();
    }

    //发现好店
    @RequestMapping("/index/goodShop")
    public RestResponse goodShop(String shopCategoryId) {

        return null;
    }


    @RequestMapping("search")
    public RestResponse search(String word) {
        return null;
    }


}
